extends CharacterBody2D

var value : int
var _texture_width : float

func init(
	texture : Texture2D,
	pos: Vector2,
	shape: Shape2D,
	_value: int
) -> void:
	$Sprite2D.texture = texture
	$CollisionShape2D.shape = shape

	position = pos
	value = _value
	_texture_width = texture.get_size().x

func _process(_delta) -> void:
	if !Global.is_game_running:
		return

	if position.x < - _texture_width / 2:
		queue_free()
		return
	position.x -= Global.G_scrollSpeed * 0.5 * _delta
